//默认lodash没有被打包是因为它使用了commonjs,rollup默认情况下只会处理es module
const commonjs = require("@rollup/plugin-commonjs");

const nodeResolve = require("@rollup/plugin-node-resolve");

//es6转换es5
const { babel } = require("@rollup/plugin-babel");

//压缩js代码
const terser = require("@rollup/plugin-terser");

module.exports = {
  //入口
  input: "./lib/index.js",
  //出口
  output: [
    {
      format: "iife",
      name: "myUtils",
      file: "./build/bundle.js",
      globals: {
        lodash: "_",
      },
    },
    // {
    //   format: "umd",
    //   name: "myUtils",
    //   file: "./build/bundle.umd.js",
    // },
    // {
    //   format: "cjs",
    //   name: "myUtils",
    //   file: "./build/bundle.cjs.js",
    // },
    // {
    //   format: "iife",
    //   name: "myUtils",
    //   file: "./build/bundle.browser.js",
    // },
  ],
  plugins: [
    commonjs(), //解决以cmj方式导出的
    nodeResolve(), //解决从node_module引入的第三方包无法打包
    babel({
      babelHelpers: "bundled",
      exclude: /node_modules/,
    }),
    terser(),
  ],
  external: ["lodash"],
};
